package com.example.dao;


import com.example.domain.ChangePwd;
import com.example.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author luo
 * login表
 */
@Mapper
public interface UserDao {

    /**
     * 登录
     * @param user
     * @return
     */
    @Select("select * from login where username = #{username} and password = #{password}")
    public User findUserByName(User user);

    /**
     * 查找username
     * @param username
     * @return
     */
    @Select("select * from login where username = #{username}")
    public User findName(String username);

    @Select("select * from login where username = #{username} and password=#{password}")
    public User findName1(String username,String password);

    /**
     * 注册
     * @param user
     * @return
     */
    @Insert("insert into login (username, password) values(#{username},#{password})")
    public Integer registerUserName(User user);

    /**
     * 修改密码
     * @param changePwd
     * @return
     */
    @Update("update login set password = #{newPassword} where username = #{username} and password = #{password}")
    public Integer changePwd(ChangePwd changePwd);
}
